home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / gfxfx / picload2.pas < prev    next >
Pascal/Delphi Source File  |  1994-04-20  |  1KB  |  51 lines

  1.  
  2. {$i-,v-}
  3.  
  4. program PictureLoader;
  5. { Another raw-picture loader (pal at $10: ColoRIX/EGA format), by Bas van Gaalen, Holland, PD}
  6. uses crt;
  7. const vseg = $a000;
  8. type
  9.   str80 = string[80];
  10.   buftp = array[0..4095] of byte;
  11.   palbuf = array[0..$2ff] of byte;
  12. var
  13.   picfile : file;
  14.   palette : palbuf;
  15.   buffer : buftp;
  16.   filename : str80;
  17.   i,bufct : longint;
  18.   nofread : integer;
  19.  
  20. procedure setpal(col,r,g,b : byte); assembler; asm
  21.   mov dx,03c8h; mov al,col; out dx,al; inc dx; mov al,r
  22.   out dx,al; mov al,g; out dx,al; mov al,b; out dx,al end;
  23.  
  24. procedure setcolors(buf : palbuf); var c : word; i : byte; begin c := 3;
  25.   for i := 1 to 255 do begin setpal(i,buf[c],buf[c+1],buf[c+2]); inc(c,3); end; end;
  26.  
  27. begin
  28.   filename := paramstr(1);
  29.   if filename = '' then begin
  30.     writeln('Please enter filename on commandline.'); halt; end;
  31.   assign(picfile,filename);
  32.   reset(picfile,1); if ioresult <> 0 then begin
  33.     writeln(filename+' not found in current dir'); halt; end;
  34.   seek(picfile,10);
  35.   blockread(picfile,palette,$300);
  36.   asm mov ax,2eh; int 10h; end;
  37.   setcolors(palette);
  38.   bufct := 0;
  39.   repeat
  40.     blockread(picfile,buffer,4096,nofread);
  41.     for i := 0 to nofread-1 do begin
  42.       port[$03cd] := (bufct+i) shr 16;
  43.       mem[vseg:(bufct+i) and $ffff] := buffer[i];
  44.     end;
  45.     inc(bufct,nofread);
  46.   until nofread < 4096;
  47.   close(picfile);
  48.   repeat until keypressed;
  49.   textmode(lastmode);
  50. end.
  51.